
import { message } from "@/components/base";
import { IOptions, ServerError } from "@/serve";

/**
 * 显示错误信息
 * @param error 
 * @param options 
 */
export function showError(error: unknown, options?: IOptions) {
    if (options?.isShowError !== false) {
        if (error instanceof ServerError) {
            errorShow(error.message || '请求错误');
        } else if (error instanceof Error) {
            errorShow(error.message || '请求错误');
        } else {
            errorShow('请求错误');
        }
    }
    return error;
}

function errorShow(content: string) {
    message.error({ content, key: content });
}

